package cn.studyjava.verify.common.base;

import cn.studyjava.verify.common.Const;
import cn.studyjava.verify.common.enums.VerifyEnum;
import cn.studyjava.verify.common.result.JsonResult;

/**
 * <p>
 * Description:
 * </p>
 * 
 * @author: zsljava
 * @version 1.0.0
 * <p>
 * History:
 * -----------------------------------------------
 * @Date: 2017年10月18日 下午2:32:00
 * @author: zsljava
 * @version 1.0.0
 * @OP: Create
 * -----------------------------------------------
 * </p>
 *
 * @since
 * @see
 */
public class BaseAction {

	public <T> JsonResult<T> buildJsonResult(T data){
		return new JsonResult<T>(Const.VERIFY_STATUS_SUCCESS, VerifyEnum.VERIFY_AUTH_SUCCESS.getCode(),  VerifyEnum.VERIFY_AUTH_SUCCESS.getMsg(), data);
	}
	
	public <T> JsonResult<T> buildJsonResult(int status, VerifyEnum verify, T data){
		return new JsonResult<T>(status, verify.getCode(), verify.getMsg(), data);
	}
	
	public <T> JsonResult<T> buildFialJsonResult(Exception e){
		return new JsonResult<T>(Const.VERIFY_STATUS_FAIL, VerifyEnum.VERIFY_AUTH_FAIL.getCode(), e.getMessage());
	}
	
	public <T> JsonResult<T> buildFialJsonResult(VerifyEnum verify){
		return new JsonResult<T>(Const.VERIFY_STATUS_FAIL, verify.getCode(), verify.getMsg());
	}
	
	public <T> JsonResult<T> buildFialJsonResult(VerifyEnum verify, T data){
		return new JsonResult<T>(Const.VERIFY_STATUS_FAIL, verify.getCode() ,verify.getMsg(), data);
	}
	
}
